package ii.zjf.week4.count;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class Add7 extends BaseAdd {

    public static void main(String[] args) throws InterruptedException {

        final CyclicBarrier cyclicBarrier = new CyclicBarrier(1, () -> {
            System.out.println("success : " + count.getCount());
        });

        Thread thread = new Thread(() -> {
            count.add();
            try {
                cyclicBarrier.await();
            } catch (InterruptedException | BrokenBarrierException e) {
                e.printStackTrace();
            }
        });

        thread.start();

    }
}
